<!DOCTYPE html>
<html lang="en">

<head>
  <meta charset="UTF-8">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>v-bind动态绑定class(对象语法)</title>
  <style>
    .active {
      color: red;
    }
  </style>
</head>

<body>
  <div id="app">
    <!-- 动态绑定class对象用法:  -->
    <!-- <h2 :class="{ 类名1:boolean, 类名2:boolean }">{{message}}</h2> -->
    <h2 class="title" :class="{ active:isActive }">{{message}}</h2>
    <h2 class="title" :class="getClasses()">{{message}}</h2>
    <button @click="change">点击变色</button>

  </div>
  <script src="../js/vue.js"></script>
  <script>
    const app = new Vue({
      el: "#app",
      data: {
        message: "你好啊",
        // active: "active",
        isActive: true
      },
      methods: {
        change() {
          this.isActive = !this.isActive
        },
        getClasses() {
          return {active: this.isActive};
        }
      },
    })
  </script>
</body>

</html>